using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.IO;
using System.Globalization;
using System.Threading;

namespace Test.Support {
	class ChangeReader {
		static void MainX() {
			CultureInfo culture=(CultureInfo)CultureInfo.CurrentCulture.Clone();
			culture.DateTimeFormat.ShortDatePattern="yyyy-MM-dd";
			culture.DateTimeFormat.LongTimePattern="HH:mm:ss";
			Thread.CurrentThread.CurrentCulture=culture;
			//----------------------------------------------------
			string qry=@"select eDeadline,Orig_Team,eFolderName,FullName,Status,ChangeDesc,cast(ChangeSummary as varchar(400))Summary,cast(Chge_Implementation_Plan as varchar(400))ImpPlan
from ework.Change_Management(nolock) join ework.efolder(nolock) on ework.change_management.efolderid = efolder.efolderid";

		StreamWriter str=	File.CreateText("Changes.txt");


		using(SqlConnection con=new SqlConnection("Server=end-ipsq06;Database=ework;app=IIS;uid=ework;pwd=84uTRatu;"))
		

			using(SqlCommand cmd=new SqlCommand(qry,con))
			{
				//Console.WriteLine(con.ConnectionTimeout);
				con.Open();
				SqlDataReader rdr=cmd.ExecuteReader();
				while(rdr.Read())
				{
					object[] ret=new object[rdr.FieldCount];
					rdr.GetValues(ret);
					foreach(object obj in ret)
					{
						str.Write(obj.ToString());
						str.Write(";");
					}
					str.WriteLine();
					str.WriteLine("--------------------------------------------------");
					//Console.WriteLine(ret[2]);
				}
				str.Flush();

				con.Close();
			}

		}
	}
}
